<template>
  <!-- 危急值上报 -->
  <div id="reportAlarmValueDetail">
    <el-divider content-position="left">基本信息</el-divider>
    <el-descriptions :column="4" labelClassName="description-label" contentClassName="description-content" border class="margin-bottom-sm">
      <el-descriptions-item>
        <template #label>
          <span>姓名</span>
        </template>
        <span>{{ mainInfo.patNa }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>病历号</span>
        </template>
        <span>{{ mainInfo.patNo }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>性别</span>
        </template>
        <span> {{ mainInfo.sex === '1' ? '男' : mainInfo.sex === '2' ? '女' : '未知' }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>年龄</span>
        </template>
        <span>{{ mainInfo.age+mainInfo.ageUnit }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>病人类型</span>
        </template>
        <span>{{ mainInfo.patTypeNa }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>科室</span>
        </template>
        <span>{{ mainInfo.reqDeptNa }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>样本类型</span>
        </template>
        <span>{{ mainInfo.sampleTypeNa }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>报告单元</span>
        </template>
        <span>{{ mainInfo.rptGroupNa }}</span>
      </el-descriptions-item>
    </el-descriptions>

    <el-divider content-position="left" v-if="!IsEmpty(obserResultInfo)" >观察记录</el-divider>
    <el-descriptions :column="1" labelClassName="description-label" contentClassName="description-content" border class="margin-bottom-sm" v-if="!IsEmpty(obserResultInfo)" >
      <el-descriptions-item>
        <template #label>
          <span>形态</span>
        </template>
        <span>{{ obserResultInfo.morphologyName }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>菌落计数</span>
        </template>
        <span>{{ obserResultInfo.strainCount }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>比例</span>
        </template>
        <span>{{ obserResultInfo.bacRate }}</span>
      </el-descriptions-item>
      <el-descriptions-item>
        <template #label>
          <span>生化实验</span>
        </template>
        <span>{{ obserResultInfo.experiment }}</span>
      </el-descriptions-item>
    </el-descriptions>

    <el-divider content-position="left">染色信息</el-divider>
    <div class="tableForm">
      <div class="tableBody">
        <vxe-table ref="bacDrugTestResultRef" height="200px;" border show-overflow :header-cell-style="setBacDrugTestResultHeaderCellStyle" :data='stainingResultList' :row-config="{ isCurrent: true }" :column-config="{ resizable: true }" :edit-config="{ trigger: 'click', mode: 'cell', showIcon: false }" :expand-config="{ expandAll: true, reserve: true }" :tree-config="{
            expandAll: true,
            transform: true,
            rowField: 'id',
            parentField: 'parentId'
          }" resizable keep-source>
          <vxe-column type="seq" width="30"></vxe-column>
          <vxe-column field="handleType" title="类型" width="200" tree-node>
            <template #default="{ row }">
              <span>{{ getIsStaticStatusDesc(row.handleType) }}</span>
            </template>
          </vxe-column>
          <vxe-column field="stainingMethNa" title="染色方法" min-width="120px">
            <template #default="{ row }">
              <span>{{ row.stainingMethNa }}</span>
            </template>
          </vxe-column>
          <vxe-column field="stainingConcNa" title="项目" min-width="120px">
            <template #default="{ row }">
              <span>{{ row.stainingConcNa }}</span>
            </template>
          </vxe-column>
          <vxe-column field="stainingConcOptNa" title="染色结果" :edit-render="{ autofocus: '.vxe-input--inner' }" min-width="120px">
            <template #default="{ row }">
              <span>{{ row.stainingConcOptNa }}</span>
            </template>
            <template #edit="{ row, rowIndex }">
              <SelectDataGrid :url="'/bac/staining/options/findStainingOptionsList'" :column="[
                  { field: 'resultCode', title: '编号' }, //列标题
                  { field: 'resultName', title: '名称' }
                ]" :isPage="false" @SelectCellClick="(e) => { SelectRowClick(e, rowIndex); }" :searchParam="{ stainingConclusionId: stainingResultTableDate.staConclusionNo }">
              </SelectDataGrid>
              <div>
                {{ row.itemNo + ' ' + row.itemNa }}
              </div>
            </template>
          </vxe-column>
          <vxe-column field="descText" title="操作记录" min-width="120px"></vxe-column>
          <vxe-column field="editTime" title="操作时间" width="130">
            <template #default="{ row }">
              <span>{{ row.editTime }}</span>
            </template>
          </vxe-column>
          <vxe-column field="userName" title="操作人" width="75"></vxe-column>
        </vxe-table>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { reactive, ref, defineExpose, getCurrentInstance } from 'vue';
import { IsEmpty, sortByField, formatDateTime } from '@/utils/common';
import { VxeMessage, VxeNotifyType } from '@/utils/CommonMessage';
import { getOptionValueByCodeGlobalOption, getOptionValueByCodeRptGroupOption } from '@/utils/SysOptionsHelper';

let { proxy }: any = getCurrentInstance();

let obserResultInfo = reactive({});
let mainInfo = reactive({}); //主记录病人信息
let stainingResultList = reactive([]); //结果

const options = [
  {
    value: '0',
    label: '涂片'
  },
  {
    value: '2',
    label: '转种'
  },
  {
    value: '1',
    label: '分纯'
  }
];

let allowEditRptTime = ref(false); /**允许编辑上报时间 */

defineExpose({
  initPage
});

function initPage(labMainInfo, formData, rows) {
  Object.assign(mainInfo, labMainInfo);
  Object.assign(obserResultInfo, formData);
  stainingResultList.push(...rows);
}

function getIsStaticStatusDesc(row) {
  if (row == 0) {
    return '涂片';
  } else if (row == 1) {
    return '纯分';
  } else if (row == 2) {
    return '转种';
  } else if (row == 3) {
    return '续培';
  } else {
    return '';
  }
}
</script>

<style lang="scss" scoped>
:deep(.vxe-modal--wrapper) {
  z-index: 10 !important;
}
:deep(.el-descriptions__label) {
  width: 120px;
}
:deep(.el-descriptions__content) {
  color: #000;
}
:deep(.vxe-cell) {
  padding-left: 5px;
}
.tableForm {
  height: calc(100% - 80px);
  .tableBody {
    height: 75%;
  }
  .formBody {
    height: 25%;
    padding: 0 25px;
    :deep(.vxe-form--item) {
      margin-right: 15px;
    }
  }
}
</style>
